get_filename_component(TARGET ${CMAKE_CURRENT_SOURCE_DIR} NAME)

include(${SRC_ROOT_DIR}/cmake/YuPath.cmake)

if(WIN32)
	if(MSVC)
		set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -utf-8")
		set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /MANIFEST:NO")
		set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /MANIFEST:NO")
	endif()
	set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG	${SRC_ROOT_DIR}/bin/debug)
	set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG	${SRC_ROOT_DIR}/export/lib/debug)
	set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG	${SRC_ROOT_DIR}/export/lib/debug)
	set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE	${SRC_ROOT_DIR}/bin/release)
	set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE	${SRC_ROOT_DIR}/export/lib/release)
	set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE	${SRC_ROOT_DIR}/export/lib/release)
else()
	set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wl,-rpath,:'$$ORGIN' -Wl,-unresolved-symbol=ignore-in=shared-libs")
	set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG	${SRC_ROOT_DIR}/bin/debug)
	set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG	${SRC_ROOT_DIR}/export/lib/debug)
	set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG	${SRC_ROOT_DIR}/export/lib/debug)
	set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE	${SRC_ROOT_DIR}/bin/release)
	set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE	${SRC_ROOT_DIR}/export/lib/release)
	set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE	${SRC_ROOT_DIR}/export/lib/release)
endif()

file(TO_CMAKE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/" SOURCEPATH)

file(GLOB_RECURSE SOURCES_FILES "${SOURCEPATH}/*.cpp" "${SOURCEPATH}/*.c"	)
file(GLOB_RECURSE HEADER_FILES 	"${SOURCEPATH}/*.h"		)

source_group(TREE "${SOURCEPATH}" PREFIX "CPP_FILES" FILES ${SOURCES_FILES})
source_group(TREE "${SOURCEPATH}" PREFIX "HEADS_FILES" FILES ${HEADER_FILES})

add_executable(${TARGET} ${SOURCES_FILES} ${HEADER_FILES})
set_target_properties(${TARGET} PROPERTIES FOLDER ${parent_dir_name})
# 为 Debug 和 Release 配置的库文件设置后缀
set_target_properties(${TARGET} PROPERTIES
		DEBUG_POSTFIX "d"
		RELEASE_POSTFIX "")
message(STATUS "module=>: ${parent_dir_name} --> ${TARGET} configure ok...")